/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.femass.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;


@Entity
@Table(name = "Inscricao")
@NamedQueries({
    @NamedQuery(name = "Inscricao.findAll", query = "SELECT i FROM Inscricao i"),
    @NamedQuery(name = "Inscricao.findByData", query = "SELECT i FROM Inscricao i WHERE i.data = :data"),
    @NamedQuery(name = "Inscricao.findByParticipantecod", query = "SELECT i FROM Inscricao i WHERE i.inscricaoPK.participantecod = :participantecod"),
    @NamedQuery(name = "Inscricao.findByEventocod", query = "SELECT i FROM Inscricao i WHERE i.inscricaoPK.eventocod = :eventocod")})
public class Inscricao implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected InscricaoPK inscricaoPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    @JoinColumn(name = "Participante_cod", referencedColumnName = "cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Participante participante;
    @JoinColumn(name = "Evento_cod", referencedColumnName = "cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Evento evento;

    public Inscricao() {
    }

    public Inscricao(InscricaoPK inscricaoPK) {
        this.inscricaoPK = inscricaoPK;
    }

    public Inscricao(InscricaoPK inscricaoPK, Date data) {
        this.inscricaoPK = inscricaoPK;
        this.data = data;
    }

    public Inscricao(int participantecod, int eventocod) {
        this.inscricaoPK = new InscricaoPK(participantecod, eventocod);
    }

    public InscricaoPK getInscricaoPK() {
        return inscricaoPK;
    }

    public void setInscricaoPK(InscricaoPK inscricaoPK) {
        this.inscricaoPK = inscricaoPK;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public Participante getParticipante() {
        return participante;
    }

    public void setParticipante(Participante participante) {
        this.participante = participante;
    }

    public Evento getEvento() {
        return evento;
    }

    public void setEvento(Evento evento) {
        this.evento = evento;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (inscricaoPK != null ? inscricaoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Inscricao)) {
            return false;
        }
        Inscricao other = (Inscricao) object;
        if ((this.inscricaoPK == null && other.inscricaoPK != null) || (this.inscricaoPK != null && !this.inscricaoPK.equals(other.inscricaoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.femass.model.Inscricao[ inscricaoPK=" + inscricaoPK + " ]";
    }

}
